﻿@model IEnumerable<Back_end.Models.Complaint>

@{
    ViewBag.Title = "举报管理";
}

@if (ViewBag.Sub == null)
{
    <h2>@ViewBag.Title</h2>;
}
else
{
    <h2></h2>
    <ul class="breadcrumb">
        <li>@Html.ActionLink("搜索", "Index")</li>
        <li>按 @ViewBag.Sub 搜索</li>
    </ul>
}

@using (Html.BeginForm("Index", "Complaints", FormMethod.Get))
{
    <div class="col-md-2">
        @Html.DropDownList("genre",
			new List<SelectListItem> {
				new SelectListItem { Text = "内容", Selected = true },
				new SelectListItem { Text = "发布者" },
				new SelectListItem { Text = "所在地" }},
			htmlAttributes: new { @class = "form-control" })
    </div>
    <div class="col-md-4 form-group">
        <div class="input-group">
            <span class="input-group-addon glyphicon glyphicon-search"></span>
            @Html.TextBox("search", null, htmlAttributes: new { @class = "form-control", @placeholder = "输入搜索条件" })
            <span class="input-group-btn">
                <button class="btn btn-primary" type="submit">搜索</button>
            </span>
        </div>
    </div>
}

<table class="table table-striped table-hover">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.UserName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.PublishedDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Text)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Location)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AllowedPublished)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.HadProcessed)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.UserName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PublishedDate)
        </td>
        <td>
            @{ string text = item.Text.Length > 5 ? item.Text.Substring(0, 5) + "..." : item.Text; }
            @text
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Location)
        </td>
        <td>
            @{  if (item.AllowedPublished == null)
                { <span class="label label-default">未审核</span> }
                else if (item.AllowedPublished == true)
                { <span class="label label-success">已通过</span> }
                else
                { <span class="label label-warning">未通过</span> }
            }
        </td>
        <td>
            @{  if (item.HadProcessed == null)
                { <span class="label label-default">未处理</span> }
                else if (item.HadProcessed == true)
                { <span class="label label-success">已处理</span> }
                else
                { <span class="label label-warning">处理中</span> }
            }
        </td>
        <td>
            @Html.ActionLink("编辑", "Edit", new { id = item.ComplaintId }) |
            @Html.ActionLink("详细", "Details", new { id=item.ComplaintId }) |
            @Html.ActionLink("删除", "Delete", new { id=item.ComplaintId })
        </td>
    </tr>
}

</table>
